package datastructure.tree;


import utils.printer.BinaryTrees;

/**
 * @Description:
 * @Author Ammar
 * @Create 2023/3/27 16:02
 */
public class Test {
    public static void main(String[] args) {
        Integer[] data = new Integer[]{
                8, 57, 12, 3, 29, 62, 31, 5, 100, 42, 79, 6, 58, 9, 93, 19, 69, 1, 17
        };
//        BinarySearchTree<Integer> binarySearchTree = new BinarySearchTree<>();
//        for (int i = 0; i < data.length; i++) {
//            binarySearchTree.add(data[i]);
//        }
        // 二叉树
//        BinaryTrees.print(binarySearchTree);
//        System.out.println();
//        System.out.println(binarySearchTree.height());
//        System.out.println(binarySearchTree.isComplete());
//        System.out.println(binarySearchTree.predecessor(binarySearchTree.getRoot().right.left.right.left).val);
//        System.out.println(binarySearchTree.successor(binarySearchTree.getRoot().left.left.right).val);
//
//        System.out.println("=================================================================================");
//        BinaryTree<Integer> binaryTree = new BinaryTree<>();
//        binaryTree.add(Arrays.asList(data));
//        BinaryTrees.println(binaryTree);
//        System.out.println("=================================================================================");
        // AVL 树

//        data = new Integer[] {
//          85, 19, 69, 3, 7, 99, 95, 2, 1, 70, 44, 58, 11, 21, 14, 93, 57, 4, 56
//        };
//        AVLTree<Integer> avlTree = new AVLTree<>();
//        for (int i = 0; i < data.length; i++) {
//            avlTree.add(data[i]);
//        }
//        BinaryTrees.println(avlTree);
        // 红黑树
        RedBlackTree<Integer> redBlackTree = new RedBlackTree<>();
        for (int i = 0; i < data.length; i++) {
            redBlackTree.add(data[i]);
        }
        BinaryTrees.println(redBlackTree);
        for (int i = 0; i < data.length; i++) {
            redBlackTree.remove(data[i]);
            System.out.println("---------------------------------------");
            System.out.println("【" + data[i] + "】");
            BinaryTrees.println(redBlackTree);
        }
    }
}
